package com.kun.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@EnableSwagger2
@Configuration
public class SwaggerConfig {

    //    配置Swagger的Bean实例Docket
    @Bean
    public Docket docket(){
        Docket docket = new Docket( DocumentationType.SWAGGER_2);
        docket.apiInfo(myApiInfo());
        return docket
                .enable(true)  //swagger启动开关
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.kun.index.controller"))  //扫描指定的包
                .build();
    }

    private ApiInfo myApiInfo(){
        Contact contact = new Contact("kun","#","2312757988@qq.com");
        return new ApiInfo(
                "fhk 's world",
                "my world",
                "1.0",
                "urn:tos",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList<VendorExtension>());

    }

}
